----------------------------------Spell Variables--------------------------------------
SPELL.m_iSpellID = 20 -- Whatever value you want as long as it doesn't override any other spells' IDs.
SPELL.m_iRange = 240
SPELL.m_sName = "Heroic Strike"
SPELL.m_sToolTip = [[You strike heroically at
					 the target, dealing 300%
					 weapon damage.]]
SPELL.m_sIcon = "devin/blackbetty/spells/warrior/heroic_strike.png"
SPELL.m_bRequiresTarget = true
SPELL.m_iManaCost = 35
SPELL.m_iCoolDown = 1
SPELL.m_iSpellType = SPELLTYPE_MAA

---------------------------------------------------------------------------------------

local range = 100

function SPELL:Cast( pl, target )
	local target = nil
	local weapon = nil
	if(pl:IsPlayer())then
		weapon = pl:GetWeapon("weapon_all")
		target = pl:GetNetworkedEntity("Target")
	else
		target = pl.Target
	end
	if(target && target:IsValid() && target != pl ) then
		pl.InSpellAnimation = true
		if(pl:IsPlayer())then
			pl:DoAnimationEvent(ACT_DI_ALYX_ANTLION)
		else
			pl:RestartGesture(ACT_DI_ALYX_ANTLION)
		end
		pl:EmitSound("devin/blackbetty/weapons/heroic_strike/heroic_swing.wav", 100, 100+math.random(-10,10))
			timer.Simple(0.45, function()
				if(target and pl:GetPos():Distance(target:GetPos()) < self.m_iRange)then
					pl:EmitSound("devin/blackbetty/weapons/heroic_strike/heroic_strike.wav", 160, 100+math.random(30,40))
					target:EmitSound("devin/blackbetty/weapons/2HMaceHitPlateCrit.wav", 150, 100+math.random(-10,-30))
					ParticleEffect( "pummel_hit", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
					ParticleEffect( "player_blood", target:GetPos() + Vector(0, 0, 46) + (target:GetAngles():Forward()*6), Angle(0,0,0), pl )
					if(SERVER)then
						local dmginfo = DamageInfo()
							if(weapon)then
								dmginfo:SetDamage( math.Round(math.random(weapon.MinWeaponDamage*3, weapon.MaxWeaponDamage*3))) --50 damage
							else
								dmginfo:SetDamage( math.Round(math.random(pl.MinDamage*2.25, pl.MaxDamage*2.25)))
							end
							dmginfo:SetDamageType( DMG_GENERIC )
							dmginfo:SetAttacker( pl )
							dmginfo:SetDamageForce( Vector( 0, 0, 1000 ) )
						target:TakeDamageInfo( dmginfo )
					end
				end
			end)
		timer.Simple(0.4, function()
				pl.InSpellAnimation = false
				pl:SetNWBool("Casting", false)
				pl:SetNWBool("Casted", false)
		end)
	end
end



